import Base from './Base'
import ProductType from './ProductType'
import ProductStyle from './ProductStyle'
import ProductStatus from './ProductStatus'
import ProductStocksIndexType from './ProductStocksIndexType'

class Product extends Base {
  constructor ({
    id = '',
    productStatus = new ProductStatus({}),
    name = '',
    code = '',
    productType = new ProductType({}),
    isHotSelling = '0',
    isAssociation = '0',
    productStyle = new ProductStyle({}),
    investmentManager = '',
    productLevel = '',
    startMoney = '1',
    managerType = '1',
    managerName = '',
    trusteeType = '1',
    trusteeName = '',
    conditions = '',
    issueBeginDate = '',
    issueEndDate = '',
    registerDate = '',
    currency = '',
    closePeriod = '',
    expires = '',
    recommendBeginDate = '',
    recommendEndDate = '',
    redemption = '',
    productStocksIndexType = new ProductStocksIndexType({}),
    buyFee = '0',
    redemptionFee = '0',
    trusteeshipFee = '',
    floatFee = '',
    otherFee = '',
    fixedFee = '',
    openDate = '',
    investmentScope = '',
    recommendReason = '',
    isDisclaimers = '0',
    disclaimers = '',
    remark = '',
    productAsset = '',
    newestProductNetvalue = {}
  }) {
    super({id})

    this.productStatus = productStatus
    this.name = name
    this.code = code
    this.productType = productType
    this.isHotSelling = isHotSelling
    this.isAssociation = isAssociation
    this.productStyle = productStyle
    this.investmentManager = investmentManager
    this.productLevel = productLevel
    this.startMoney = startMoney
    this.managerType = managerType
    this.managerName = managerName
    this.trusteeType = trusteeType
    this.trusteeName = trusteeName
    this.conditions = conditions
    this.issueBeginDate = issueBeginDate
    this.issueEndDate = issueEndDate
    this.registerDate = registerDate
    this.currency = currency
    this.closePeriod = closePeriod
    this.expires = expires
    this.recommendBeginDate = recommendBeginDate
    this.recommendEndDate = recommendEndDate
    this.redemption = redemption
    this.productStocksIndexType = productStocksIndexType
    this.buyFee = buyFee
    this.redemptionFee = redemptionFee
    this.trusteeshipFee = trusteeshipFee
    this.floatFee = floatFee
    this.otherFee = otherFee
    this.fixedFee = fixedFee
    this.openDate = openDate
    this.investmentScope = investmentScope
    this.recommendReason = recommendReason
    this.isDisclaimers = isDisclaimers
    this.disclaimers = disclaimers
    this.remark = remark
    this.productAsset = productAsset
    this.newestProductNetvalue = newestProductNetvalue
  }
  // 获取列表 - 登录后调用
  static async find (params) {
    let res = await Product.$http.get(`${Product.$name}/list`, {params})
    return res.map(v => new this(v))
  }
  // 获取简单列表 - 登录前调用
  static async findSimple (params) {
    let res = await Product.$http.get(`${Product.$name}/simple_list`, {params})
    return res.map(v => new this(v))
  }
}
// 静态属性
Product.$name = '/product'
export default Product
